home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / citsrc6K05.lha / libroom.c < prev    next >
C/C++ Source or Header  |  1996-08-29  |  2KB  |  73 lines

  1. /*
  2. *                libroom.c
  3. *
  4. * Library for room code.
  5. */
  6. /*
  7. *                History
  8. *
  9. * 85Nov15 HAW  Created.
  10. */
  11. #include "ctdl.h"
  12. /*
  13. *                Contents
  14. *
  15. *    getRoom()        load given room into RAM
  16. *    putRoom()        store room to given disk slot
  17. */
  18. aRoom          roomBuf;          /* Room buffer          */
  19. extern rTable *roomTab;          /* RAM index          */
  20. extern CONFIG cfg;
  21. FILE          *roomfl;          /* Room file descriptor     */
  22. int          thisRoom = LOBBY;      /* Current room          */
  23. /*
  24. * getRoom()
  25. *
  26. * Gets the designated room.
  27. */
  28. void getRoom(int rm)
  29.   {
  30.   long int s;
  31.   /* load room #rm into memory starting at buf */
  32.   thisRoom    = rm;
  33.   s = (long) ((long) rm * (long) RB_TOTAL_SIZE);
  34.   fseek(roomfl, s, 0);
  35.   if (fread(&roomBuf, RB_SIZE, 1, roomfl) != 1)   
  36.     {
  37.     crashout(" ?getRoom(): read failed//error or EOF (1)!");
  38.     
  39.     }
  40.   crypte(&roomBuf, RB_SIZE, rm);
  41.   if (fread(roomBuf.msg, MSG_BULK, 1, roomfl) != 1)   
  42.     {
  43.     crashout(" ?getRoom(): read failed//error or EOF (2)!");
  44.     
  45.     }
  46.   
  47.   }
  48. /*
  49. * putRoom()
  50. *
  51. * stores room in buf into slot rm in ctdlroom.sys.
  52. */
  53. void putRoom(int rm)
  54.   {
  55.   long int s;
  56.   s = (long) ((long) rm * (long) RB_TOTAL_SIZE);
  57.   if (fseek(roomfl, s, 0) != 0) 
  58.   crashout(" ?putRoom(): fseek failure!");
  59.   crypte(&roomBuf, RB_SIZE, rm);
  60.   if (fwrite(&roomBuf, RB_SIZE, 1, roomfl) != 1)   
  61.     {
  62.     crashout("?putRoom() crash!//0 returned!!!(1)");
  63.     
  64.     }
  65.   if (fwrite(roomBuf.msg, MSG_BULK, 1, roomfl) != 1)   
  66.     {
  67.     crashout("?putRoom() crash!//0 returned!!!(2)");
  68.     
  69.     }
  70.   crypte(&roomBuf, RB_SIZE, rm);
  71.   
  72.   }
  73.